import { uploadType, getAreaObj } from '@/utils/util'
import {configToSearch,toSearchHandle} from '@/views/datacenter/business/utils/index'
const tableConfig = {
	stripe: true,
	border: true,
	maxHeight: '80vh',
	columns: [
		{
			label: '所属区域',
			prop: 'belongAreaName',
			type: 'input',
		},
		// { label: '统一社会信用代码', prop: 'creditCode' },
		{ label: '机构名称', prop: 'organizationName' },
		{ label: '联系人', prop: 'deputyUserName' },
		{ label: '联系方式', prop: 'deputyUserPhone',plusXing: '5,2' },
		{ label: '申请时间', prop: 'applyDate' },
		{ label: '发放金额', prop: 'grantAmount' },
		{ label: '发放时间', prop: 'grantDate' },
		{
			label: '是否可信',
			prop: 'isBelievable',
			custome: 'tag',
			dicData: [
				{ label: '否', value: 0,type:'danger' },
				{ label: '是', value: 1,type:'success' },
			],
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}
const detailConfig:any = {
	label: '老年大学补贴详情',
	prop: 'base1',
	inline: false,
	showBtn: false,
	labelPosition: 'left',
	column: [
		// 基础信机构基本情况息
		{
			type: 'DividerHtml',
			modelValue: '机构基本情况',
			span: 24,
		},
		{
			label: '机构名称',
			prop: 'organizationName',
			type: 'text',
			maxlength: '50',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '法人代表',
			prop: 'deputyUserName',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '联系电话',
			prop: 'deputyUserPhone',
			type: 'text',
			maxlength: '11',
			showWordLimit: true,
			span: 8,
		},
		{
			label:"所属区划",
			prop:'areas_name',
			type:'AplidAreaSelect',
			span:8
		},
		{
			label: '室内教学场地面积',
			prop: 'placeInsideSquare',
			type: 'text',
			append:'平方米',
			span: 8,
		},
		{
			label: '室外教学场地面积',
			prop: 'placeOutsideSquare',
			type: 'text',
			append:'平方米',
			span: 8,
		},
		// 申请内容
		{
			type: 'DividerHtml',
			modelValue: '申请内容',
			span: 24,
		},
		{
			label: '绩效考核等级',
			prop: 'examineResult',
			propName:'examineResultLabel',
			code:'EXAMINE',
			api:'geiDictItemList',
			type: 'remoteSelect',
			span: 8,
		},
		{
			label: '开设课程',
			prop: 'courseContent',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '1月份课程次数',
			prop: 'monthJanCourseTimes',
			type: 'text',
			append:'次',
			span: 8,
		},
		{
			label: '绩效1月份课程总服务人次',
			prop: 'monthJanServiceTimes',
			type: 'input',
			append:"次",
			span: 8,
		},
		{
			label: '2月份课程次数',
			prop: 'monthFebCourseTimes',
			type: 'text',
			append:'次',
			span: 8,
		},
		{
			label: '绩效2月份课程总服务人次',
			prop: 'monthFebServiceTimes',
			type: 'input',
			append:"次",
			span: 8,
		},
		{
			label: '3月份课程次数',
			prop: 'monthMarCourseTimes',
			type: 'text',
			append:'次',
			span: 8
		},
		{
			label: '绩效3月份课程总服务人次',
			prop: 'monthMarServiceTimes',
			type: 'input',
			append:"次",
			span: 8
		},
		{
			label: '4月份课程次数',
			prop: 'monthAprCourseTimes',
			type: 'text',
			append:'次',
			span: 8
		},
		{
			label: '绩效4月份课程总服务人次',
			prop: 'monthAprServiceTimes',
			type: 'input',
			append:"次",
			span: 8
		},
		{
			label: '5月份课程次数',
			prop: 'monthMayCourseTimes',
			type: 'text',
			append:'次',
			span: 8
		},
		{
			label: '绩效5月份课程总服务人次',
			prop: 'monthMayServiceTimes',
			type: 'input',
			append:"次",
			span: 8
		},
		{
			label: '6月份课程次数',
			prop: 'monthJunCourseTimes',
			type: 'text',
			append:'次',
			span: 8
		},
		{
			label: '绩效6月份课程总服务人次',
			prop: 'monthJunServiceTimes',
			type: 'input',
			append:"次",
			span: 8
		},
		{
			label: '7月份课程次数',
			prop: 'monthJulCourseTimes',
			type: 'text',
			append:'次',
			span: 8
		},
		{
			label: '绩效7月份课程总服务人次',
			prop: 'monthJulServiceTimes',
			type: 'input',
			append:"次",
			span: 8
		},
		{
			label: '8月份课程次数',
			prop: 'monthAugCourseTimes',
			type: 'text',
			append:'次',
			span: 8
		},
		{
			label: '绩效8月份课程总服务人次',
			prop: 'monthAugServiceTimes',
			type: 'input',
			append:"次",
			span: 8,
		},
		{
			label: '9月份课程次数',
			prop: 'monthSeptCourseTimes',
			type: 'text',
			append:'次',
			span: 8
		},
		{
			label: '绩效9月份课程总服务人次',
			prop: 'monthSeptServiceTimes',
			type: 'input',
			append:"次",
			span: 8
		},
		{
			label: '10月份课程次数',
			prop: 'monthOctCourseTimes',
			type: 'text',
			append:'次',
			span: 8
		},
		{
			label: '绩效10月份课程总服务人次',
			prop: 'monthOctServiceTimes',
			type: 'input',
			append:"次",
			span: 8
		},
		{
			label: '11月份课程次数',
			prop: 'monthNovCourseTimes',
			type: 'text',
			append:'次',
			span:8
		},
		{
			label: '绩效11月份课程总服务人次',
			prop: 'monthNovServiceTimes',
			type: 'input',
			append:"次",
			span: 8
		},
		{
			label: '12月份课程次数',
			prop: 'monthDecCourseTimes',
			type: 'text',
			append:'次',
			span: 8
		},
		{
			label: '绩效12月份课程总服务人次',
			prop: 'monthDecServiceTimes',
			type: 'input',
			append:"次",
			span: 8
		},
		{
			label: '合计年课程总次数',
			prop: 'courseTotalTimes',
			type: 'text',
			append:'次',
			span:8
		},
		{
			label: '合计年课程总服务人数',
			prop: 'totalServiceTimes',
			type: 'text',
			append:'人',
			span: 8
		},

		// 申请材料
		{
			type: 'DividerHtml',
			modelValue: '申请材料',
			span: 24,
		},
		{
			label: '市民卡或助老卡刷卡记录',
			prop: 'swipeRecordFiles',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			span: 8
		},
		{
			label: '养老机构提供课程签到表、开班明细',
			prop: 'courseOpeningDetailImgs',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			span: 8
		},
		{
			label: '养老机构与老年大学合作协议',
			prop: 'cooperateAgreementImgs',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			span: 8
		},
		{
			label: '老年大学资格证书',
			prop: 'universityPermitImgs',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			span: 8
		},
		{
			label: '持有民政部门核准的 A 级（含）以上养老机构资质 1 年以上证明材料',
			prop: 'holdEvidenceImgs',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			span: 8
		},
		{
			label: '老年大学教师授课名单（老年大学盖章）',
			prop: 'universityProfessorImgs',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			span: 8
		},
		{
			label: '负责人学历证书',
			prop: 'burdenUserDiplomaImgs',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			span: 8
		},
		{
			label: '负责人养老服务上岗证书',
			prop: 'burdenUserPermit',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			span: 8
		},
		{
			label: '教学明细提前7天在区民政局备案证明材料',
			prop: 'teachingEvidenceImgs',
			type: 'upload',
			fileType: uploadType.fileMetaType,
			listType: 'text',
			labelPosition: 'top',
			showFileList: true,
			limit: 4,
			multiple: true,
			span: 8
		},
		// 审核意见
		{
			type: 'DividerHtml',
			modelValue: '审核意见',
			span: 24,
		},
		{
			label: '单位意见',
			prop: 'institutionNote',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
			span: 8
		},
		{
			label: '单位审批人',
			prop: 'institutionApprovalUser',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 8
		},
		{
			label: '单位审批时间',
			prop: 'institutionApprovalDate',
			type: 'date',
			format:'YYYY年MM月DD日',
			valueFormat:'YYYY-MM-DD',
			span: 8
		},
		{
			label: '区民政审批意见',
			prop: 'areaCivilNote',
			type: 'text',
			maxlength: '140',
			showWordLimit: true,
			span: 8
		},
		{
			label: '区民政审批人',
			prop: 'areaCivilApprovalUser',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 8
		},
		{
			label: '区民政审批时间',
			prop: 'areaCivilApprovalDate',
			type: 'date',
			format:'YYYY年MM月DD日',
			valueFormat:'YYYY-MM-DD',
			span: 8
		},
		// 审批结果
		{
			type: 'DividerHtml',
			modelValue: '审批结果',
			span: 24,
		},
		{
			label: '审批结果',
			prop: 'approvalResult',
			propName:'approvalResultLabel',
			code:'RESULT',
			api:'getDictItemList',
			type: 'remoteSelect',
			span: 8,
		},
		{
			label: '审批人',
			prop: 'approvalUserName',
			type: 'text',
			maxlength: '20',
			showWordLimit: true,
			span: 8,
		},
		{
			label: '审批时间',
			prop: 'approvalDate',
			type: 'date',
			format:'YYYY年MM月DD日',
			valueFormat:'YYYY-MM-DD',
			span: 8,
		},
		{
			label: '补贴发放总金额',
			prop: 'grantAmount',
			type: 'text',
			append:'元',
			span: 8,
		},
		{
			label: '补贴发放时间',
			prop: 'grantDate',
			type: 'date',
			format:'YYYY年MM月DD日',
			valueFormat:'YYYY-MM-DD',
			span: 8,
		},
	],
}

const moreSearchConfig:any = {
	inline: true,
	showBtn: false,
	labelPosition: 'left',
	column:[
		...configToSearch(detailConfig.column)
	]
}
const importConfig = {
	tabSteps: [
		{
			label: '下载模板',
			download: '下载模板',
			active: 1,
			rules: [
				{
					label: '下载最新导入模板。共1个：',
					children: [
						{
							label: '《老年大学补贴信息表》',
							link: true,
							url: 'dpElderlyUniversitySubsidy_downloadTemplate',
						},
					],
				},
			],
		},
		{
			label: '导入《老年大学补贴信息表》',
			description: '',
			uploadTip: '老年大学补贴信息表',
			active: 2,
			url: 'dpElderlyUniversitySubsidy_import',
			code: 3002,
			rules: [
				{
					label: '导入规则说明:',
					children: [
						{
							label: '(1)导入模式为“覆盖导入”，待导入的老年大学补贴信息会覆盖平台已存在的',
						},
					],
				},
			],
		},
	],
}
export const baseConfig: any = {
	pageName: '老年大学补贴',
	dictcodes: ['EXAMINE','RESULT','SUBSIDY_APPLICATION_DISBURSEMENT_TYPE'],
	rowKey: 'id',
	tipLabel: 'organizationName',
	exportMqTopic: '/ning/export',
	api: {
		moreSearch:'view_dpElderlyUniversitySubsidy_search',
		index: 'dpElderlyUniversitySubsidy_page',
		delete: 'dpElderlyUniversitySubsidy_del',
		export: 'dpElderlyUniversitySubsidy_export',
		import: 'dpElderlyUniversitySubsidy_import',
	},
	auth: {
		index: 'view_dpElderlyUniversitySubsidy_page',
		mulitSet: 'mulitSet',
		delete: 'view_dpElderlyUniversitySubsidy_del',
		// export: 'view_dpElderlyUniversitySubsidy_export',
		// import: 'view_dpElderlyUniversitySubsidy_import',
	},
	paramsObj: {
		code: 3002,
	},
	menuBtn: [
		{
			icon: 'editor',
			label: '查看详情',
			type: 'primary',
			operate: 'detail',
			auth: '',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '65%',
	},
	searchConfig: {
		inline: true,
		showBtn: true,
		labelPosition: 'left',
		column: [
			{
				label: '信用代码',
				prop: 'creditCode',
				type: 'input',
				span: 6,
			},
			{
				label: '机构名称',
				prop: 'organizationName',
				type: 'input',
				span: 6,
			},
			{
				label: '联系方式',
				prop: 'deputyUserPhone',
				type: 'tel',
				maxLength: '11',
				span: 6,
			},
			{
				label: '所属地区',
				propName: 'areas_name',
				type: 'AplidAreaSelect',
				span: 6,
			},
			{
				label: '联系人',
				prop: 'deputyUserName',
				type: 'input',
				span: 6,
			},
			{
				label: '申请时间',
				prop: 'applyTimeBetween',
				type: 'daterange',
				format: 'YYYY年MM月DD日',
				valueFormat: 'YYYY-MM-DD',
				span: 12,
			},
		],
	},
	moreSearchConfig,
	detailConfig,
	tableConfig,
	importConfig,
	beforeOnLoadFormate: async (params) => {
		params = toSearchHandle(moreSearchConfig,{},params)
		if(params.applyTimeBetween){
			params.applyTimeBetween = params.applyTimeBetween.join(',')
		}else{
			params.applyTimeBetween = undefined
		}
		let areasObj = getAreaObj(params.areas_name, 'belong')
		return Promise.resolve({
			...params,
			...areasObj,
			areas_name: undefined,
		})
	},
	onLoadFormate: async (arr) => {
		const tableData = arr.map((item) => {
			const areas_name = getAreaObj(item, 'belong')
			console.log('拿到区域', areas_name)
			return {
				...item,
				areas_name,
			}
		})
		return Promise.resolve(Object.freeze(tableData))
	},
}
